package com.weiaibenpao.demo.chislim.ui.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.weiaibenpao.demo.chislim.R;
import com.weiaibenpao.demo.chislim.bean.MallBean;

/**
 * Created by lenovo on 2018/1/8.
 */

public class DjqMallAdapter extends BaseQuickAdapter<MallBean.ListBean,BaseViewHolder> {


    public DjqMallAdapter() {
        super(R.layout.djq_mall_item,null);
    }

    @Override
    protected void convert(BaseViewHolder helper, MallBean.ListBean item) {
        helper.setText(R.id.mallTitle,item.getTreadmillTitle())
                .setText(R.id.mallIntro,item.getTreadmillIntro());
        Glide.with(mContext)
                .load(item.getTreadmillImgUrl())
                .into((ImageView) helper.getView(R.id.mallImg));
//      helper.addOnClickListener(R.id.mallImg);
    }

//    /**
//     * 数据的绑定显示
//     *
//     * @param holder
//     * @param position
//     */
//    @Override
//    public void onBindViewHolder(final ViewHolder holder, final int position) {
//        //绑定事件
//        if (mOnItemClickListener != null) {
//            holder.mallImg.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                    mOnItemClickListener.setOnItemClick(holder.mallImg, ((MallBean.ListBean) marathonList.get(position)).getTmallUrl());
//                }
//            });
//
//        }
//        holder.mallTitle.setText(((MallBean.ListBean) marathonList.get(position)).getTreadmillTitle());
//        holder.mallIntro.setText(((MallBean.ListBean) marathonList.get(position)).getTreadmillIntro());
//        Glide.with(context)
//                .load(((MallBean.ListBean) marathonList.get(position)).getTreadmillImgUrl())
//                .into(holder.mallImg);
//    }
//
//    //刷新
//    public void initFresh(ArrayList<MallBean.ListBean> dataList){
//        marathonList = dataList;
//        notifyDataSetChanged();
//    }
//
//    //加载更多
//    public void initAdd(ArrayList<MallBean.ListBean> dataList){
//        marathonList.addAll(dataList);
//        notifyDataSetChanged();
//    }
//
//    /**
//     * 要显示的item数目
//     * @return
//     */
//    @Override
//    public int getItemCount() {
//        return marathonList.size();
//    }
//
//    //自定义的ViewHolder，持有每个Item的的所有界面元素
//    public class ViewHolder extends RecyclerView.ViewHolder {
//        public ImageView mallImg;
//        public TextView mallTitle;
//        public TextView mallIntro;
//
//        public ViewHolder(View view) {
//            super(view);
//            mallImg = (ImageView) view.findViewById(R.id.mallImg);
//            mallTitle = (TextView) view.findViewById(R.id.mallTitle);
//            mallIntro = (TextView) view.findViewById(R.id.mallIntro);
//        }
//    }
}
